﻿@model SportsStore.WebUI.Models.CartIndexViewModel

@{
    ViewBag.Title = "购物车";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>我的购物车</h2>
<table class="table">
    <thead>
        <tr>
            <th>数量</th>
            <th>名称</th>
            <th>价格</th>
            <th>小计</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var cl in Model.Cart.Lines)
        {
            <tr>
                <td>@cl.Quantity</td>
                <td>@cl.Product.Name</td>
                <td>@cl.Product.Price</td>
                <td>@((cl.Product.Price * cl.Quantity).ToString("C"))</td>
                <td>
                    @using (Html.BeginForm("RemoveFromCart", "Cart"))
                    {
                        @Html.Hidden("productId", cl.Product.ProductID)
                        @Html.HiddenFor(x => x.ReturnUrl)
                        <input class="btn btn-sm btn-warning" type="submit" value="删除" />
                    }
                </td>
            </tr>
        }
    </tbody>
    <tfoot>
        <tr>
            <td colspan="3" class="text-right">总价</td>
            <td>
                @Model.Cart.ComputeTotalValue().ToString("C")
            </td>
        </tr>
    </tfoot>
</table>
<div class="text-center">
    <a href="@Model.ReturnUrl" class="btn btn-primary">继续购物</a>
    @Html.ActionLink("立即结账","Checkout",null,new {@class="btn btn-primary"})
</div>